import { add, jian } from "@/store/modules/count"
import { RootState } from "@/types/store"

import { useDispatch, useSelector } from "react-redux"
import { Link } from "react-router-dom"

function Page2() {
  const { count } = useSelector((state: RootState) => state.countReducer)
  const dispatch = useDispatch()

  const addOne = () => {
    dispatch(add())
  }
  const delTwo = () => {
    dispatch(jian(2))
  }
  return (
    <div>
      <Link to='/'>back1</Link>
      this is page2--{ count }
      <button onClick={addOne}>add+1</button>
      <button onClick={delTwo}>jian-2</button>
    </div>
  )
}

export default Page2